package phi.engine.core
{
	import flash.utils.getTimer;

	public class GameTime
	{
		// Protected vars
		protected var startTime :Number = 0;
		protected var updateTime :Number = 0;
		
		/**
		 * Constructor
		 * @param time
		 */
		public function GameTime( startTime:Number=0, updateTime:Number=0 )
		{
			this.startTime  = startTime;
			this.updateTime = updateTime;
			
			if( startTime == 0 )	
				this.startTime = getTimer();
		}
		
		/**
		 * The amount of game time since the start of the game.
		 */
		public function get totalGameTime():Number
		{
			return getTimer() - startTime;
		}
		
		/**
		 * The amount of elapsed game time since the last update.
		 */
		public function get elapsedGameTime():Number
		{
			return getTimer() - updateTime;	
		}
		
		public function update():void
		{
			updateTime = getTimer();
		}
		
		public function clone():GameTime
		{
			return new GameTime( startTime , updateTime );
		}
	}
}